package com.borya.action.web;

import org.apache.log4j.Logger;

import com.alibaba.fastjson.JSONObject;
import com.borya.action.BaseAction;
import com.borya.framework.annotation.Action;
import com.borya.framework.annotation.Autowired;
import com.borya.framework.annotation.JsonResult;
import com.borya.framework.annotation.UrlMapping;
import com.borya.framework.core.ServerRequest;
import com.borya.framework.core.ServerResponse;
import com.borya.service.web.WebUserService;

@UrlMapping("/w/user/")
@Action
public class UserAction extends BaseAction{

	private Logger log = Logger.getLogger(getClass());
	@Autowired("webUserServiceImpl")
	private WebUserService userService;
	
	@UrlMapping("login") 
	@JsonResult
	public String login(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.login(json);
		log.info("INFO[" + json + "],OUT[" + result + "]");
		return result;
	}
	
	@UrlMapping("loginout") 
	@JsonResult
	public String logout(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.loginout(json);
		log.info("INFO[" + json + "],OUT[" + result + "]");
		return result;
	}
	
	@UrlMapping("sentCode")
	@JsonResult
	public String sentCode(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.sentCode(json);
		log.info("INFO[:" + json + "],OUT[" + result + "]");
		return result;
	}
	
	@UrlMapping("submitInfo") 
	@JsonResult
	public String submitInfo(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.submitInfo(json);
		log.info("INFO[" + json + "],OUT[" + result + "]");
		return result;
	}
	
	@UrlMapping("submitMerchantInfo") 
	@JsonResult
	public String submitMerchantInfo(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.submitMerchantInfo(json);
		log.info("INFO[" + json + "],OUT[" + result + "]");
		return result;
	}
	
	@UrlMapping("checkDealerId") 
	@JsonResult
	public String checkDealerId(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.checkDealerId(json);
		log.info("INFO[" + json + "],OUT[" + result + "]");
		return result;
	}
	
	@UrlMapping("findScopePool") 
	@JsonResult
	public String findScopePool(ServerRequest request,ServerResponse response) {
		JSONObject json = getJson(request);
		String result = userService.findScopePool(json);
		log.info("INFO[" + json + "],OUT[" + result + "]");
		return result;
	}
}